package Operation;
import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class Borrowoperation implements Interface {
    @Override
    public void work(BookList bookList) {
        System.out.println("输入你要借阅的图书的书名：");
        Scanner scanner = new Scanner(System.in);
        String book = scanner.nextLine();
        int Quantity = bookList.getQuantity();
        for (int i = 0; i < Quantity; i++) {
            Book book1 = bookList.getpoi(i);
            if (book.equals(book1.getName())) {
                if(!book1.isLend()){
                System.out.println("找到了这本书");
                book1.setLend(true);
                break;
            } else {
                System.out.println("没有找到");
            }
            }else {
                System.out.println("书已被借出");
            }
        }
    }
}
